﻿@using DTcms.Model;
@{
   Layout = "~/Areas/admin/Views/Shared/_Layout.cshtml";
   ViewBag.Title = "订单发货窗口";
   DTcms.Model.orders m = ViewData["model"] as DTcms.Model.orders;
   List<SelectListItem> expressList = ViewData["expressList"] as List<SelectListItem>;
}
@section HeaderContent{
<script>
   var api = top.dialog.get(window); //获取窗体对象
   var W = api.data; //获取父对象
   //页面加载完成执行
   $(function () {
      //设置按钮及事件
      api.button([{
         value: '确定',
         callback: function () {
            submitForm();
         },
         autofocus: true
      }, {
         value: '取消',
         callback: function () { }
      }]);
   });

   //提交表单处理
   function submitForm() {
      var currDocument = $(document); //当前文档
      //验证表单
      if ($("#ddlExpressId").val() == "") {
         top.dialog({
            title: '提示',
            content: '请选择配送方式！',
            okValue: '确定',
            ok: function () { },
            onclose: function () {
               $("#ddlExpressId", currDocument).focus();
            }
         }).showModal(api);
         return false;
      }
      //组合参数
      var postData = {
         "order_no": $("#spanOrderNo", W.document).text(), "edit_type": "order_express",
         "express_id": $("#ddlExpressId").val(), "express_no": $("#txtExpressNo").val()
      };
      //判断是否需要输入物流单号
      if ($("#txtExpressNo").val() == "") {
         top.dialog({
            title: '提示',
            content: '您确定不填写物流单号吗？',
            okValue: '确定',
            ok: function () {
               //发送AJAX请求
               W.sendAjaxUrl(api, postData, "/tools/admin_ajax.ashx?action=edit_order_status");
            },
            cancelValue: '取消',
            cancel: function () {
               $("#txtExpressNo", currDocument).focus();
            }
         }).showModal(api);
         return false;
      } else {
         //发送AJAX请求
         W.sendAjaxUrl(api, postData, "/tools/admin_ajax.ashx?action=edit_order_status");
         return false;
      }
      return false;
   }
</script>
}

<form id="form1"  method="post" action="#">
<div class="div-content">
  <dl>
    <dt>更改配送方式</dt>
    <dd>
      <div class="rule-single-select">
        @Html.DropDownList("ddlExpressId", new SelectList( expressList, "Value", "Text", m.express_id))
      </div>
    </dd>
  </dl>
  <dl>
    <dt>发货物流单号</dt>
    <dd>@Html.TextBox("txtExpressNo", m.express_no, new { @class="input txt"})</dd>
  </dl>
</div>
</form>